package com.jfinal.ext.util.qrcode;

import java.io.File;

public class QrCodeTest {

    public static void main(String[] args) throws Exception {
/*        // 存放在二维码中的内容
        String text = "我是小铭";
        // 嵌入二维码的图片路径
        String imgPath = "";
        // 生成的二维码的路径及名称
        String destPath = "f:/qrCode/qrcode/jam.jpg";
        //生成二维码
        QRCodeUtil.encode(text, imgPath, destPath, true);
        // 解析二维码
        String str = QRCodeUtil.decode(destPath);
        // 打印出解析出的内容
        System.out.println(str);*/

test();

    }

    static final String proj = "http://dev.wishcloud.cn/shop";
    static final String path = "f:/qrcode/";

    public static void test() {
            String id = "3";
        String url = proj + "/files/qrcode/qr_" + id + ".jpg";
        String text = proj + "/html/register/index.html?ids=" + id;
        if (!new File(path+id).exists()) {
            try {
                System.out.println("ss");
                String imgPath = path + "ic_launcher.png";
                String destPath = path + "qr_" + id + ".jpg";
                String bgPath = path + "ic_bg.jpg";
                BgImage bg = new BgImage(bgPath, 190, 550, 141, 141);
                QRCodeUtil.encode(text, imgPath, destPath, true, bg);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println(url);
    }

}
